# import the necessary packages
import cv2 as cv
import numpy as np
import argparse
import imutils

# consturct the argument parser and parse the arguments
ap = argparse.ArgumentParser()
ap.add_argument("-i", "--image", required=True, help="Path to the image")
args = vars(ap.parse_args())

# load the image and show it
image = cv.imread(args["image"])
cv.imshow("Original", image)

# NOTE: Translation (shifting) an image is given by a Numpy matrix in
# the form:
# [[1,0,shiftX],[0,1,shiftY]]
# You simply need to specify how many pixels you want to shift the image
# in the X and Y direction -- let's translate the imaeg 25 pixels to the
# right and 50 pixels down
M = np.float32([[1, 0, 25], [0, 1, 50]])
shifted = cv.warpAffine(image, M, (image.shape[1], image.shape[0]))
cv.imshow("Shifted Down and Right", shifted)

# now,let's shift the image 50 pixels to the left and 90 pixels up, we
# accomplish this using negeative valeus
M = np.float32([[1, 0, -50], [0, 1, -90]])
shifted = cv.warpAffine(image, M, (image.shape[1], image.shape[0]))
cv.imshow("Shifted Up and Left", shifted)
cv.waitKey(0)
# finally,let's use our helper function in imutils to shift the image down
# 100 pixels
shifted = imutils.translate(image,0,100)
cv.imshow("Shifted Down",shifted)
cv.waitKey(0)
